<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "{{%record}}".
 *
 * @property int $id
 * @property string $openid 用户id
 * @property string $name 用户姓名
 * @property string $mobile 用户电话
 * @property string $number 号码牌
 * @property int $awards_id 中的奖项
 * @property int $created_at 中奖时间
 * @property Awards $awards
 */
class Record extends \yii\db\ActiveRecord
{

    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%record}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['openid', 'name', 'mobile', 'number'], 'required'],
            [['awards_id', 'created_at'], 'integer'],
            [['openid', 'number'], 'string', 'max' => 32],
            [['name', 'mobile'], 'string', 'max' => 255],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'openid' => 'Openid',
            'name' => 'Name',
            'mobile' => 'Mobile',
            'number' => 'Number',
            'awards_id' => 'Awards ID',
            'created_at' => 'Created At',
        ];
    }

    public function getAwards()
    {
        return $this->hasOne(Awards::className(), ['id' => 'awards_id']);
    }
}
